//
//  huiyuanDetailsViewController.m
//  daogouApp
//
//  Created by panquanReabam.com on 15-6-2.
//  Copyright (c) 2015年 jiezsoft.com. All rights reserved.
//

#import "servicePurchasedViewController.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "HAODEsingleton.h"
#import "ProductView.h"
#import "UIViewExt.h"
#import "RDVTabBarController.h"
#import "MJRefresh.h"
#import "serviceCell.h"

#import "shangpingview.h"
#import "UIButton+WebCache.h"
#import "addhuiyuanlistViewController.h"
#import "AttributedLabel.h"
#import "huiyuandengjiViewController.h"
#import "ToResiduePayViewController.h"
#import "huiyuanDetailsViewController.h"
#import "saoyisaoViewController.h"
#import "reasonTypeViewController.h"
@interface servicePurchasedViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate,UITextViewDelegate>
@property(nonatomic,strong)NSString*DocType;
@property(nonatomic,strong)NSString*sats;
@property (strong, nonatomic) NSString*GuideCode;

@property (strong, nonatomic) NSString*memberId;
@end

@implementation servicePurchasedViewController


{UIView*beizhuView;
    UILabel *line;
    UIScrollView*myscrollView;
    HAODEsingleton* commdity;
    UIImageView* imageview;
    UILabel *lineLabel1;
    ProductView *clothView;
    NSMutableArray*Memo;
    NSMutableArray*Integral;
    NSMutableArray*Amount;
    NSMutableArray*CreateDate;
    float lastContentOffset;
    UILabel *lineLabel111;
    UIButton*agreementBtn;
    UIButton*agreementBtn1;
    BOOL saveAccount;
    BOOL saveAccount1;
    UITableView *table;
    UITableView *table_list;
    BOOL saveAccount2;
    BOOL saveAccount3;
    AttributedLabel*name;
    NSMutableArray*dealPrice;
    NSMutableArray*headImage;
    NSMutableArray*itemId;
    NSMutableArray*itemName;
    NSMutableArray*quantity;
    NSMutableArray*salePrice;
    NSMutableArray*specId;
    NSMutableArray* specName;
    NSMutableArray* specPrice;
    NSMutableArray* shopCartIds;
    NSMutableArray*isSelect;
    NSMutableArray*itemType;
    UIButton*hejibuyBtn1;

    UITextView* tv;
    UILabel * label;
    UIImageView*imagess;
    UIButton*buyBtn1;
    UIButton*buyBtn2;
    UITextField*xianjinTextFied;
    UITextField*fuwuTextFied;
    
    UIView*diview;
    UIButton*jiantouBtn2;
    UIButton*jiantouBtn1;
    UIButton*jiantouBtn3;
    UIButton*ming;
    UISearchBar *search;
    UIButton* sxBtn;
    UIButton*jiantouBtn;
    UIButton*cardBtn;
   
    UITextField*searchTextField;
    UIButton*daogouname;
    UIView*view1;
    BOOL isHaveDian;
    UIScrollView*mainScroll;
    UIScrollView*MYmainScroll;
    UILabel*huiyuanname;
    UIButton *tureBtn;
    UILabel*dingdanhao1;
    UIImageView*Seximage;
    UIButton *jiantouBtn4;
    UIButton *touBtn;
    UIButton *touBtn1;
    UIButton *touBtn2;
    UIButton *touBtn3;
    UIButton *touBtn4;
    UIButton *ToObtain;
    UIButton *btnDone;
    UIButton *jiagemingxi;
    shangpingview*shangpingView;
    UITextField*jiuliaoTextFied;
    UIButton*xuanze;
    NSMutableArray* arrrss;
    UILabel*shengyuzhifujiage;
    UILabel*shengyuzhifu;
    UILabel*shengyuzhifujiage1;
    UIButton* suobtn;
    UIView* view;
    UIView*view2;
    NSMutableArray *selectFeatureCodeArray;
    NSMutableArray *orderItemIds;
    NSMutableArray *selectimageArray;
    NSMutableArray *selectshuliangArray;
    NSMutableArray *selectduoshaoArray;
    NSMutableArray *keyishopCartIds;
    
    NSMutableArray *keyidealPrice;
    NSMutableArray *keyiitemCode;
    NSMutableArray *keyiitemName;
    NSMutableArray *keyiheadImage;
    NSMutableArray *keyispecName;
    NSMutableArray *keyiquantity;
    
    NSMutableArray *selectguigeArray;
    NSMutableArray *selectitemCodeArray;
    NSMutableArray * itemCode;
    
    NSMutableArray * refundQuantity;
    UILabel* noLabel;
    
    
    
    UIButton*xiugaiview;
    UILabel*shu;
    UITextField*jiageTextFied;
    UIView*toumingtu;
    UIView*footview;
    
    
    
    
    
    
    

}
@synthesize alt = alt;
-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[self rdv_tabBarController] setTabBarHidden:YES];
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    self.navigationController.delegate = self;
    
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
      commdity=[HAODEsingleton shared];
    
    if ([commdity.xiangqing isEqualToString:@""]) {
    
        
        
        
      [self add];
        
    
    
    
    }else {
    
        fuwuTextFied.text=commdity.content;
     huiyuanname.text=[NSString stringWithFormat:@"%@(%@)",   commdity.userName, commdity.Phone];
     huiyuanname.text=[NSString stringWithFormat:@"%@",  commdity.adress];
        if (![commdity.Sex isEqual:[NSNull null]]) {
            
            if ([commdity.Sex isEqualToString:@"男"]) {
                
                
                Seximage.image=[UIImage imageNamed:@"nan"];
                
            }else{
                
                Seximage.image=[UIImage imageNamed:@"nv"];
                
            }
            
            
            
        }

    }
    
    

}
-(void)add{
    
  
    [noLabel removeFromSuperview];
    dealPrice= [[NSMutableArray alloc] init];
    headImage= [[NSMutableArray alloc] init];
    itemId= [[NSMutableArray alloc] init];
    itemName= [[NSMutableArray alloc] init];
    quantity= [[NSMutableArray alloc] init];
    salePrice= [[NSMutableArray alloc] init];
    specId= [[NSMutableArray alloc] init];
    specName = [[NSMutableArray alloc] init];
    specPrice = [[NSMutableArray alloc] init];
    shopCartIds= [[NSMutableArray alloc] init];
    isSelect= [[NSMutableArray alloc] init];
    selectFeatureCodeArray=[[NSMutableArray alloc] init];
    selectimageArray=[[NSMutableArray alloc] init];
    selectshuliangArray=[[NSMutableArray alloc] init];
    selectduoshaoArray=[[NSMutableArray alloc] init];
    itemType=[[NSMutableArray alloc] init];
    selectguigeArray=[[NSMutableArray alloc] init];
    orderItemIds=[[NSMutableArray alloc] init];
    itemCode=[[NSMutableArray alloc] init];
    refundQuantity=[[NSMutableArray alloc] init];
    selectguigeArray=[[NSMutableArray alloc] init];
    selectitemCodeArray=[[NSMutableArray alloc] init];
    keyishopCartIds=[[NSMutableArray alloc] init];
    
    keyidealPrice=[[NSMutableArray alloc] init];
    keyiitemCode=[[NSMutableArray alloc] init];
    keyiitemName=[[NSMutableArray alloc] init];
    keyiheadImage=[[NSMutableArray alloc] init];
    keyispecName=[[NSMutableArray alloc] init];
    keyiquantity=[[NSMutableArray alloc] init];
    
    table_list = [[UITableView alloc]initWithFrame:CGRectMake(0, self.navigationController.navigationBar.bottom, ScreenWidth, ScreenHeight-self.navigationController.navigationBar.bottom-self.tabBarController.tabBar.height) style:UITableViewStylePlain];
    table_list.delegate = self;
    table_list.dataSource = self;
    table_list.separatorStyle=UITableViewCellSeparatorStyleNone;
    
    
    [self.view addSubview:table_list];
    if (commdity.memberId!=nil) {
        
        [name removeFromSuperview];
         [sxBtn removeFromSuperview];
        
        sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, 30, 30)];
        [sxBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//      [sxBtn addTarget:self action:@selector(saoyisao:) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
        self.navigationItem.rightBarButtonItem = myBtnBtn;
        
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            NSMutableDictionary *param = [NSMutableDictionary new];
            [param setValue:Token forKey:@"tokenId"];
            [param setValue:commdity.memberId forKey:@"memberId"];
      
            
            
            
            NSLog(@"====%@",param);
            [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
            
            
            [HttpRequest requestData:@"Business/Member/Orders" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    
                    NSLog(@"====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        
                        NSMutableArray* arrr=[[NSMutableArray alloc]init];
                        arrr=[severDataDict.dataDict objectForKey:@"orderItem"];
                        [self jiazaiview];
                    if (arrr.count>0) {
                    
                        for (NSDictionary* dicc in arrr )
                        {
                            [dealPrice addObject:[dicc valueForKey:@"dealPrice"]];
                            [headImage addObject:[dicc valueForKey:@"headImageFull"]];
                            [itemId addObject:[dicc valueForKey:@"itemId"]];
                            [itemName addObject:[dicc valueForKey:@"itemName"]];
                            
                            [salePrice addObject:[dicc valueForKey:@"salePrice"]];
                            [specId addObject:[dicc valueForKey:@"specId"]];
                            [shopCartIds addObject:[dicc valueForKey:@"id"]];
                            [specName addObject:[dicc valueForKey:@"specName"]];
                            [specPrice addObject:[dicc valueForKey:@"specPrice"]];
                            [itemType addObject:[dicc valueForKey:@"itemType"]];
                            [itemCode addObject:[dicc valueForKey:@"itemCode"]];
                            [refundQuantity addObject:[dicc valueForKey:@"refundQuantity"]];
                            
                            NSString*str=[NSString stringWithFormat:@"%d",  [[dicc valueForKey:@"quantity"]intValue]-[[dicc valueForKey:@"refundQuantity"]intValue]] ;
                            [quantity addObject:str];
                            
                            [keyiquantity addObject:str];
                            
                            if ([[dicc valueForKey:@"refundQuantity"]intValue]<[[dicc valueForKey:@"quantity"]intValue]) {
                                
                                [keyidealPrice addObject:[dicc valueForKey:@"dealPrice"]];
                                [keyishopCartIds addObject:[dicc valueForKey:@"id"]];
                                [keyiitemName addObject:[dicc valueForKey:@"itemName"]];
                                [keyiitemCode addObject:[dicc valueForKey:@"itemCode"]];
                                [keyiheadImage addObject:[dicc valueForKey:@"headImageFull"]];
                                [keyispecName addObject:[dicc valueForKey:@"specName"]];
                                [keyiquantity addObject:str];
                                
                                
                                
                            }

                        }
                    }else{
                        
                            [self jiazaiview];
                            noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
                            noLabel.text=@"无数据";
                            noLabel.textColor=[UIColor blackColor];
                            noLabel.textAlignment=NSTextAlignmentCenter;
                            noLabel.center=self.view.center;
                            [self.view addSubview:noLabel];

                        
                        
                        }
                        

                        
                        if (itemName.count==0) {
                           [buyBtn2 removeFromSuperview];
                            buyBtn2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*430/750, ScreenHeight-48, ScreenWidth*320/750, 48)];
                            [buyBtn2 setTitle:@"服务登记" forState:UIControlStateNormal];
                            buyBtn2.backgroundColor=qianhuicolor;
//                            [buyBtn2 addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
                             buyBtn2.titleLabel.font=[UIFont systemFontOfSize:titleNamefot];
                            [buyBtn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            [self.view addSubview:buyBtn2];
                        }else{
                            [buyBtn2 removeFromSuperview];
                            UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(ScreenWidth-180, diview.bottom, 160, 45)];
                            shangpingxinxi.text=[NSString stringWithFormat:@"共 %ld 条购买记录",  itemName.count];
                            shangpingxinxi.textColor=[UIColor blackColor];
                            shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
                            shangpingxinxi.textAlignment=NSTextAlignmentRight;
                            [view2 addSubview:shangpingxinxi];
                            buyBtn2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*430/750, ScreenHeight-48, ScreenWidth*320/750, 48)];
                            [buyBtn2 setTitle:@"服务登记" forState:UIControlStateNormal];
                            buyBtn2.backgroundColor=luseColor;
                            [buyBtn2 addTarget:self action:@selector(queren:) forControlEvents:UIControlEventTouchUpInside];
                             buyBtn2.titleLabel.font=[UIFont systemFontOfSize:titleNamefot];
                            [buyBtn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            [self.view addSubview:buyBtn2];
                            xuanze=[[UIButton alloc]initWithFrame:CGRectMake(10, diview.bottom+6, 30, 30)];
                            [xuanze setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
                            [xuanze setImage:[UIImage imageNamed:@"quans"] forState:UIControlStateNormal];
                            xuanze.titleLabel.textAlignment=UIControlContentHorizontalAlignmentLeft;
                            [view2 addSubview:xuanze];
                            [xuanze addTarget:self action:@selector(xuanze:) forControlEvents:
                             UIControlEventTouchUpInside];
                         
                            UIButton*quanxuanze=[[UIButton alloc]initWithFrame:CGRectMake(xuanze.right+5, diview.bottom+6, 30, 30)];
                            
                            [quanxuanze setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                            [quanxuanze setTitle:@"全选" forState:UIControlStateNormal ];
                            quanxuanze.titleLabel.font=[UIFont systemFontOfSize:15];
                            [view2 addSubview:quanxuanze];

                        }

                        [table_list reloadData];
                    
                        [hejibuyBtn1 removeFromSuperview];
                        
                        
                        hejibuyBtn1=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth*430/750, 48)];
                        [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"已选商品%@件",@"0"] forState:UIControlStateNormal];
                        hejibuyBtn1.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0];
                        [hejibuyBtn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        hejibuyBtn1.alpha=0.8;
                        hejibuyBtn1.titleLabel.textAlignment=NSTextAlignmentLeft;
                        hejibuyBtn1.titleLabel.font=[UIFont systemFontOfSize:titleNamefot];
                        
                        [self.view addSubview:hejibuyBtn1];
                        
                        

                        
                    
                    
                    
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                    }
                    
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];

            
            
            
        
        
        }else{
            
            view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
            view.backgroundColor=zuiqianhuicolor;
            
            sxBtn = [[UIButton alloc] initWithFrame:CGRectMake( 2, 4, 50/2, 50/2)];
            [sxBtn setImage:[UIImage imageNamed:@"sousuo"] forState:UIControlStateNormal];
            //[sxBtn addTarget:self action:@selector(sou) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:sxBtn];
            
            searchTextField = [[UITextField alloc] initWithFrame:CGRectMake(sxBtn.right,0, ScreenWidth*450/750,65/2)];
            [searchTextField setBorderStyle:   UITextBorderStyleNone]; //外框类型
            searchTextField.placeholder = @"  会员/手机号/姓名"; //默认显示的字
            searchTextField.font = [UIFont systemFontOfSize: 14];
            searchTextField.tag=22;
            searchTextField.returnKeyType = UIReturnKeyDone;
            searchTextField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X
            //  searchTextField.delegate = self;
            [searchTextField setUserInteractionEnabled:NO];
            [view addSubview:searchTextField];
            
            suobtn=[[UIButton alloc]initWithFrame:CGRectMake(sxBtn.right, 0, ScreenWidth*400/750,60)];
            [suobtn addTarget:self action:@selector(suobtn:) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:suobtn];
            self.navigationItem.titleView = view;
            
            
            
            
            
            sxBtn = [[UIButton alloc] initWithFrame:CGRectMake(30, 0.0, 30, 30)];
            [sxBtn setImage:[UIImage imageNamed:@"saoyisao-hui"] forState:UIControlStateNormal];
            [sxBtn addTarget:self action:@selector(saoyisao:) forControlEvents:UIControlEventTouchUpInside];
            UIBarButtonItem* myBtnBtn = [[UIBarButtonItem alloc] initWithCustomView:sxBtn];
            self.navigationItem.rightBarButtonItem = myBtnBtn;
       
            
            
            
            name=[[AttributedLabel alloc]initWithFrame:CGRectMake(ScreenWidth/2-150, ScreenHeight/2-50, 300, 20)];
            name.text= @"温馨提示：请搜索或者扫描会员购买记录！";

            name.textAlignment=NSTextAlignmentCenter;
            NSInteger count = [name.text length];
             name.textColor=shenhuicolor;
            [name setColor:qianhuicolor fromIndex:0 length:count-5];
            [name setColor:shenhuicolor fromIndex:5 length:14];
           
            [name setFont:[UIFont systemFontOfSize:16] fromIndex:0 length:count-2];
            [name setFont:[UIFont systemFontOfSize:16] fromIndex:count-2 length:2];
            [self.view addSubview:name];

      
   
    
        }
   
    
}
-(void)saoyisao:(UIButton *)sender {
    
    commdity.sat=@"HUIyuan";
    saoyisaoViewController*de = [[saoyisaoViewController alloc] init];
    
    [self.navigationController pushViewController:de animated:YES];
}
-(void)jiazaiview{

    view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
    view.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    
    self.navigationItem.titleView =view;
    UILabel* label11=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
    label11.text=@"会员购买记录";
    label11.textColor=[UIColor blackColor];
    label11.font=[UIFont systemFontOfSize:tetlefot];
    label11.textAlignment=NSTextAlignmentCenter;
    [view addSubview:label11];
    
    
    self.memberId=commdity.memberId;
    
    
    view2=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 250/2)];
    view2.backgroundColor=[UIColor whiteColor];
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(ScreenWidth-30,70/2-7,8, 13);
    [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    [jiantou addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
    [view2 addSubview:jiantou];
    NSString *s = [NSString stringWithFormat:@"%@(%@)",   commdity.userName, commdity.Phone];
    UIFont *font = [UIFont systemFontOfSize:16];
    CGSize size = CGSizeMake(320, 2000);
    CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
    huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 12, labelsize.width+3, 16)];
    huiyuanname.text=[NSString stringWithFormat:@"%@(%@)",   commdity.userName, commdity.Phone];
    huiyuanname.textColor=[UIColor blackColor];
    huiyuanname.font=[UIFont systemFontOfSize:16];
    [view2 addSubview:huiyuanname];
    
    suobtn=[[UIButton alloc]initWithFrame:CGRectMake(150, 12, ScreenWidth,60)];
   [suobtn addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
    [view2 addSubview:suobtn];
    Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(huiyuanname.right, 10, 20, 20)];
    if (![commdity.Sex isEqual:[NSNull null]]) {
        
        if ([commdity.Sex isEqualToString:@"男"]) {
            
            
            Seximage.image=[UIImage imageNamed:@"nan"];
            
        }else{
            
            Seximage.image=[UIImage imageNamed:@"nv"];
            
        }
        
        [view2 addSubview:Seximage];
        
    }
    
    huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, ScreenWidth-30, 30)];
    huiyuanname.text=[NSString stringWithFormat:@"%@",  commdity.adress];
    huiyuanname.textColor=shenhuicolor;
    huiyuanname.numberOfLines=2;
    huiyuanname.font=[UIFont systemFontOfSize:14];
    [view2 addSubview:huiyuanname];
    
    diview=[[UIView alloc]initWithFrame:CGRectMake(0, 70, ScreenWidth, 10)];
    diview.backgroundColor=zuiqianhuicolor;
    [view2 addSubview:diview];
    UILabel *line911=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
    line911.backgroundColor=qianhuicolor;
    [diview addSubview:line911];
    UILabel *line91=[[UILabel alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 0.35)];
    line91.backgroundColor=qianhuicolor;
    [diview addSubview:line91];

    
    UILabel *lineLabel15=[[UILabel alloc] initWithFrame:CGRectMake(15, 250/2-0.35, ScreenWidth-30, 0.35)];
    lineLabel15.backgroundColor=qianhuicolor;
    [view2 addSubview:lineLabel15];
    
    
    UIView*footerview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 100)];
    footerview.backgroundColor=[UIColor whiteColor];
   table_list .tableHeaderView=view2;
   table_list .tableFooterView=footerview;
}
-(void)xuanze:(UIButton*)sender
{
    
    
    saveAccount1=!saveAccount1;
    if (saveAccount1) {
        
        [sender setImage:[UIImage imageNamed:@"gous"] forState:UIControlStateNormal];
        
        
        
        orderItemIds =[shopCartIds mutableCopy];
        selectFeatureCodeArray =[itemName mutableCopy];
        selectimageArray =[headImage mutableCopy];
        selectshuliangArray =[quantity mutableCopy];
        selectduoshaoArray =[dealPrice mutableCopy];
        selectitemCodeArray =[itemCode mutableCopy];
        selectguigeArray =[specName mutableCopy];
        
         NSNumber *sum11 = [selectshuliangArray valueForKeyPath:@"@sum.floatValue"];
        [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"已选商品%@件",sum11] forState:UIControlStateNormal];
        
        
        [table_list reloadData];
        
    }
    else
    {
        
        
        selectFeatureCodeArray=[[NSMutableArray alloc] init];
        orderItemIds=[[NSMutableArray alloc] init];
        selectimageArray=[[NSMutableArray alloc] init];
        selectshuliangArray=[[NSMutableArray alloc] init];
        selectduoshaoArray=[[NSMutableArray alloc] init];
        selectguigeArray=[[NSMutableArray alloc] init];
        selectitemCodeArray=[[NSMutableArray alloc] init];
        
        
        
        [sender setImage:[UIImage imageNamed:@"quans"] forState:UIControlStateNormal];
        [table_list reloadData];
        NSNumber *sum11 = [selectshuliangArray valueForKeyPath:@"@sum.floatValue"];
        [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"已选商品%@件",sum11] forState:UIControlStateNormal];
        
    }
    
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    


}






- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView ==table_list) {
        
        return [itemId count];
        
    }
    if (tableView == table) {
        return [selectimageArray count];
        
    }
    
    
    
    
    
    return [itemId count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    serviceCell* cell = (serviceCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"serviceCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    UIButton*jiantou = [[UIButton alloc]init];
    jiantou.frame = CGRectMake(0,0, 8, 13);
    [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
    
    //    cell.accessoryView = jiantou;
    
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
  if (tableView ==table_list) {
    cell.saveAccount=YES;
    
    
    [cell.imageview.layer setCornerRadius:5.0];
    [cell.imageview.layer setBorderWidth:0.3];
    [cell.imageview.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
    [cell.imageview.layer setBorderColor:colorref2];//边框颜色
    [cell.imageview setImageWithURL:[NSURL URLWithString:[headImage objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@""]];
    
    
    
    cell.shopCartId=[shopCartIds objectAtIndex:indexPath.row];
    
    cell.title.text =[NSString stringWithFormat:@"%@%@",[itemCode objectAtIndex:indexPath.row],[itemName objectAtIndex:indexPath.row]];
    
    cell.title.font=[UIFont systemFontOfSize:15];
    cell.title.textColor=[UIColor blackColor];
    
    cell.title.numberOfLines=2;
    
    if ([[specName objectAtIndex:indexPath.row]isEqualToString:@""]) {
        cell.guige.text =[NSString stringWithFormat:@"%@",@" "];
    }else{
        cell.guige.text =[NSString stringWithFormat:@"%@",[specName objectAtIndex:indexPath.row]];}
    cell.guige.font=[UIFont systemFontOfSize:contenfot];
    cell.guige.textColor=zhonghuiColor;
    
    
    
    cell.shuliang.text =[NSString stringWithFormat:@"%.f",  [[quantity objectAtIndex:indexPath.row]floatValue]];
    cell.shuliang.font=[UIFont systemFontOfSize:contenfot];
    
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:indexPath.row]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
 
      cell.jiage.text =[NSString stringWithFormat:@"￥%@",  formattedNumberString];
      cell.jiage.font=[UIFont systemFontOfSize:17];
      cell.jiage.textColor=hongsecolor;
      
      NSMutableAttributedString *AttributedSt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",  formattedNumberString]];
      
      [AttributedSt addAttribute:NSFontAttributeName
       
                           value:[UIFont systemFontOfSize:14]
       
                           range:NSMakeRange(0, 1)];
      
      [AttributedSt addAttribute:NSForegroundColorAttributeName
       
                           value:hongsecolor
       
                           range:NSMakeRange(0, 1)];
      
      
      cell.jiage.attributedText = AttributedSt;

    cell.xiugaijiage=[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:indexPath.row]];
   
    if  ([orderItemIds containsObject:[shopCartIds objectAtIndex:indexPath.row]]){
        
        
        cell.xuanzeimage.image=[UIImage imageNamed:@"gous"];
        cell.saveAccount=NO;
        
    }


    

    if (itemId.count !=indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
    
    if (itemId.count ==indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
}

if (tableView ==table) {
    
    
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    cell.saveAccount=YES;
    
    
    [cell.imageview.layer setCornerRadius:5.0];
    [cell.imageview.layer setBorderWidth:0.3];
    [cell.imageview.layer setMasksToBounds:YES];
    CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){ 0, 0, 0, 0.3 });
    [cell.imageview.layer setBorderColor:colorref2];//边框颜色
    [cell.imageview setImageWithURL:[NSURL URLWithString:[selectimageArray objectAtIndex:indexPath.row]] placeholderImage:[UIImage imageNamed:@""]];
    
    
    cell.xuanzeimage.image=[UIImage imageNamed:@"gous"];
    cell.xuanzeimage.userInteractionEnabled=NO;
    cell.shopCartId=[shopCartIds objectAtIndex:indexPath.row];
    
    cell.title.text =[NSString stringWithFormat:@"%@%@",[selectitemCodeArray objectAtIndex:indexPath.row],[selectFeatureCodeArray objectAtIndex:indexPath.row]];
    
    cell.title.font=[UIFont systemFontOfSize:15];
    cell.title.textColor=[UIColor blackColor];
    
    cell.title.numberOfLines=2;
    
    if ([[selectguigeArray objectAtIndex:indexPath.row]isEqualToString:@""]) {
        cell.guige.text =[NSString stringWithFormat:@"%@",@" "];
    }else{
        cell.guige.text =[NSString stringWithFormat:@"%@",[selectguigeArray objectAtIndex:indexPath.row]];}
    
    cell.guige.font=[UIFont systemFontOfSize:14];
    cell.guige.textColor=zhonghuiColor;
    
    
    
    cell.shuliang.text =[NSString stringWithFormat:@"%.f",  [[selectshuliangArray objectAtIndex:indexPath.row]floatValue]];
    cell.shuliang.font=[UIFont systemFontOfSize:14];
    
    NSString*GoldPrice=[NSString stringWithFormat:@"%@",[selectduoshaoArray objectAtIndex:indexPath.row]];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:GoldPrice.floatValue]];
    cell.jiage.text =[NSString stringWithFormat:@"￥%@",  formattedNumberString];
    cell.jiage.font=[UIFont systemFontOfSize:17];
    cell.jiage.textColor=hongsecolor;
    
    NSMutableAttributedString *AttributedSt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"￥%@",  formattedNumberString]];
    
    [AttributedSt addAttribute:NSFontAttributeName
     
                         value:[UIFont systemFontOfSize:14]
     
                         range:NSMakeRange(0, 1)];
    
    [AttributedSt addAttribute:NSForegroundColorAttributeName
     
                         value:hongsecolor
     
                         range:NSMakeRange(0, 1)];
    
    
    cell.jiage.attributedText = AttributedSt;

    //        cell.xiugaijiage=[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:indexPath.row]];
    [cell.xiugai setBackgroundImage :[UIImage imageNamed:@"bianji.png"] forState:UIControlStateNormal];
    [cell.xiugai addTarget:self action:@selector(xiugai:) forControlEvents:UIControlEventTouchUpInside];
    
    
    if (selectimageArray.count !=indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(15, 120-0.35, ScreenWidth-30, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
    
    if (selectimageArray.count ==indexPath.row+1) {
        UILabel *lineLabel31=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.35, ScreenWidth, 0.35)];
        lineLabel31.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel31];
        
    }
    
    
    
    
}

return cell;
}
//修改按钮
-(void)xiugai:(UIButton*)sender{
    
    [xiugaiview removeFromSuperview];
    UIButton* button=(UIButton * )sender;
    serviceCell* cell=(serviceCell* )button.superview.superview;
    cell.saveAccount=NO;
    
    
    toumingtu=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    toumingtu.backgroundColor=[UIColor clearColor];
    
    // 手势
    UITapGestureRecognizer *singleFingerOne = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyBoad)];
    singleFingerOne.numberOfTouchesRequired = 1; //手指数
    singleFingerOne.numberOfTapsRequired = 1; //tap次数
    singleFingerOne.delegate = self;
    [toumingtu addGestureRecognizer:singleFingerOne];
    [footview addSubview:toumingtu];
    
    
    xiugaiview=[[UIButton alloc]initWithFrame:CGRectMake(cell.imageview.right+10, 0, ScreenWidth, 120)];
    xiugaiview.backgroundColor=zuiqianhuicolor;
    [cell addSubview:xiugaiview];
    
    UILabel* cjjlabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, 50, 16)];
    cjjlabel.text=@"成交价";
    cjjlabel.textColor=shenhuicolor;
    cjjlabel.font=[UIFont systemFontOfSize:16];
    [xiugaiview addSubview:cjjlabel];
    
    
    jiageTextFied=[[UITextField alloc]initWithFrame:CGRectMake(cjjlabel.right+10,  30, 150, 18)];
    
    jiageTextFied.keyboardType = UIKeyboardTypeDecimalPad;
    jiageTextFied.borderStyle = UITextBorderStyleNone;
    jiageTextFied.font = [UIFont systemFontOfSize: contenfot];
    jiageTextFied.textColor=[UIColor blackColor];
    jiageTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
    jiageTextFied.tag=sender.tag;
    jiageTextFied.text=[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:sender.tag]];
    [jiageTextFied setUserInteractionEnabled:NO];
    jiageTextFied.font=[UIFont systemFontOfSize:18];
    jiageTextFied.delegate = self;
    jiageTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
    [xiugaiview addSubview:jiageTextFied];
    
    
    UILabel* shulianglabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 75, 50, 16)];
    shulianglabel.text=@"数量";
    shulianglabel.textColor=shenhuicolor;
    shulianglabel.font=[UIFont systemFontOfSize:15];
    [xiugaiview addSubview:shulianglabel];
    
    
    UIImageView*shuimageview=[[UIImageView alloc]initWithFrame:CGRectMake(shulianglabel.right+10, 70, 110, 30)];
    shuimageview .image=[UIImage imageNamed:@"tianjias"];
    [xiugaiview addSubview:shuimageview];
    
    shu=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 110, 30)];
    shu.text=[NSString stringWithFormat:@"%@",  cell.shuliang.text];
    shu.textColor=[UIColor blackColor];
    shu.center=shuimageview.center;
    shu.textAlignment=NSTextAlignmentCenter;
    shu.font=[UIFont systemFontOfSize:15];
    [xiugaiview addSubview:shu];
    
    UIButton*jian=[[UIButton alloc]initWithFrame:CGRectMake(shulianglabel.right+10, 70, 30, 30)];
    [jian addTarget:self action:@selector(jian:) forControlEvents:UIControlEventTouchUpInside];
    jian.tag=sender.tag;
    [xiugaiview addSubview:jian];
    commdity.status=[NSString stringWithFormat:@"%ld",sender.tag];
    UIButton*jia=[[UIButton alloc]initWithFrame:CGRectMake(shulianglabel.right+10+90,70, 30, 30)];
    jia.tag=sender.tag;
    [jia addTarget:self action:@selector(jia:) forControlEvents:UIControlEventTouchUpInside];
    [xiugaiview addSubview:jia];
    //    [self heji];
}
-(void)jia:(UIButton*)sender{
    
    UIButton* button=(UIButton * )sender;
    serviceCell* cell=(serviceCell* )button.superview.superview;
    
    if (cell.shuliang.text .intValue==[[keyiquantity objectAtIndex:sender.tag]intValue]) {
        [self showAlertMessage:@"服务的数量不能超过购买时候的数量！"];
    }else{
        
        int d;
        d=shu.text.intValue;
        d++;
        NSLog(@"---------%ld",sender.tag);
        
        
        NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:quantity];
        [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
        quantity = mutableArray;
        cell.shuliang.text=[NSString stringWithFormat:@"%d", d];
        shu.text=[NSString stringWithFormat:@"%d", d];
        [selectshuliangArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
 
    }
    
    
    
}

-(void)jian:(UIButton*)sender{
    
    UIButton* button=(UIButton * )sender;
    serviceCell* cell=(serviceCell* )button.superview.superview;
    
    if ([cell.shuliang.text isEqualToString:@"1"]) {
        [self showAlertMessage:@"数量不能为 0 件！"];
        
        
    }else{
        
        int d;
        d= shu.text.intValue;
        d--;
        NSLog(@"---------%ld",sender.tag);
        
        NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:quantity];
        [mutableArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];
        quantity = mutableArray;//now the array has been "updated"
        cell.shuliang.text=[NSString stringWithFormat:@"%d", d];
        shu.text=[NSString stringWithFormat:@"%d", d];
        
        
        [selectshuliangArray replaceObjectAtIndex:sender.tag withObject:[NSString stringWithFormat:@"%d", d]];

        
    }
    
    
}


- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  120;
}




- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    
    
    if (tableView ==table_list) {
        
        UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
        serviceCell *sharecell=(serviceCell *)cell;
        sharecell.saveAccount=! sharecell.saveAccount;
        
        if (!sharecell.saveAccount) {
            
            
            
            [selectFeatureCodeArray addObject:[NSString stringWithFormat:@"%@",[itemName objectAtIndex:indexPath.row]]];
            [selectimageArray addObject:[headImage objectAtIndex:indexPath.row]];
            [selectshuliangArray addObject:[quantity objectAtIndex:indexPath.row]];
            [selectduoshaoArray addObject:[NSString stringWithFormat:@"%@",[dealPrice objectAtIndex:indexPath.row]]];
            [selectguigeArray addObject:[specName objectAtIndex:indexPath.row]];
            [selectitemCodeArray addObject:[itemCode objectAtIndex:indexPath.row]];
            [orderItemIds addObject:[shopCartIds objectAtIndex:indexPath.row]];
            
            
            
            
            UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
            serviceCell *sharecell=(serviceCell *)cell;
            sharecell.xuanzeimage.image=[UIImage imageNamed:@"gous"];
            
            
            
            if (orderItemIds.count==shopCartIds.count) {
                [xuanze setImage:[UIImage imageNamed:@"gous"] forState:UIControlStateNormal];
                
            }
        }
        else{
            UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
            serviceCell *sharecell=(serviceCell *)cell;
            [xuanze setImage:[UIImage imageNamed:@"quans"] forState:UIControlStateNormal];
            sharecell.xuanzeimage.image=[UIImage imageNamed:@"quans"];
            if (selectFeatureCodeArray.count>0) {
                
                for (int i=0; i<selectFeatureCodeArray.count; i++) {
                    
                    NSString *codeStr = [selectFeatureCodeArray objectAtIndex:i];
                    if ([codeStr isEqualToString:[NSString stringWithFormat:@"%@",[itemName objectAtIndex:indexPath.row]]] ) {
                        
                        [selectguigeArray removeObjectAtIndex:i];//从指定索引移除
                        [orderItemIds removeObjectAtIndex:i];//从指定索引移除
                        [selectFeatureCodeArray removeObjectAtIndex:i];//从指定索引移除
                        [selectimageArray removeObjectAtIndex:i];//从指定索引移除
                        [selectshuliangArray removeObjectAtIndex:i];//从指定索引移除
                        [selectduoshaoArray removeObjectAtIndex:i];//从指定索引移除
                        [selectitemCodeArray removeObjectAtIndex:i];//从指定索引移除
                    }
                }
            }
        }
        
        
        NSNumber *sum11 = [selectshuliangArray valueForKeyPath:@"@sum.floatValue"];
        [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"已选商品%@件",sum11] forState:UIControlStateNormal];
        NSLog(@"--＝＝＝＝＝＝-------%@",selectFeatureCodeArray);
    }
}
#pragma mark - Table view delegate




#pragma mark - Table view delegate

-(void)suobtn:(UIButton*)sender{
    
    [orderItemIds removeAllObjects];//从指定索引移除
    [selectFeatureCodeArray removeAllObjects];//从指定索引移除
    [selectimageArray removeAllObjects];//从指定索引移除
    [selectshuliangArray removeAllObjects];//从指定索引移除
    [selectduoshaoArray removeAllObjects];//从指定索引移除
    
    [selectguigeArray removeAllObjects];//从指定索引移除

    [selectitemCodeArray removeAllObjects];//从指定索引移除
    [MYmainScroll removeFromSuperview];
    
    
     commdity.xiangqing=@"";
    
    addhuiyuanlistViewController *detailViewController = [[addhuiyuanlistViewController alloc] init];

    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
    
}

-(void)xiangqing:(UIButton*)sender{
    
    
    commdity.xiangqing=@"wu";
    commdity.gengxin=@"";
    huiyuanDetailsViewController *detailViewController = [[huiyuanDetailsViewController alloc] init];
    
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
    
}


//服务登记////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


- (void)textFieldDidChange:(UITextField *)TextField{
    
    
    
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:xianjinTextFied.text.doubleValue]];
    
    [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"合计￥%@",formattedNumberString] forState:UIControlStateNormal];
    
    
    
}

-(void)queren:(UIButton*)sender{
    
    
    
    
    if (!selectFeatureCodeArray.count >0)
    {
        [self showAlertMessage:@"请选择服务商品！"];
    }
    else{
        
        [table_list removeFromSuperview];
        
        
        [searchTextField removeFromSuperview];
        [sxBtn removeFromSuperview];
        [view removeFromSuperview];
        [self.navigationItem.titleView  removeFromSuperview];
        
        view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
        view.backgroundColor=[UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
        
        self.navigationItem.titleView =view;
        UILabel* label11=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth*555/750, 65/2)];
        label11.text=@"服务登记";
        label11.textColor=[UIColor blackColor];
        label11.font=[UIFont systemFontOfSize:tetlefot];
        label11.textAlignment=NSTextAlignmentCenter;
        [view addSubview:label11];
        
        
        
        table = [[UITableView alloc]initWithFrame:CGRectMake(0, self.navigationController.navigationBar.bottom, ScreenWidth, ScreenHeight-self.navigationController.navigationBar.bottom-self.tabBarController.tabBar.height) style:UITableViewStylePlain];
        table.delegate = self;
        table.dataSource = self;
        table.separatorStyle=UITableViewCellSeparatorStyleNone;
        
        
        [self.view addSubview:table];
        
        
        
        
        view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 80/2+250/2+10)];
        view1.backgroundColor=[UIColor whiteColor];
        
        UIView* disev=[[UIView alloc]initWithFrame:CGRectMake(0, 40, ScreenWidth, 10)];
        disev.backgroundColor=zuiqianhuicolor;
        [view1 addSubview:disev];
        UILabel *line1=[[UILabel alloc] initWithFrame:CGRectMake(0, 40, ScreenWidth, 0.35)];
        line1.backgroundColor=qianhuicolor;
        [view1 addSubview:line1];
        UILabel *line2=[[UILabel alloc] initWithFrame:CGRectMake(0, 40+10-0.35, ScreenWidth, 0.35)];
        line2.backgroundColor=qianhuicolor;
        [view1 addSubview:line2];
        UILabel* duogou=[[UILabel alloc]initWithFrame:CGRectMake(15, 25/2, 40, 15)];
        duogou.text=[NSString stringWithFormat:@"员工"];
        duogou.textColor=zhonghuiColor;
        duogou.font=[UIFont systemFontOfSize:15];
        [view1 addSubview:duogou];
        
        
        
        NSUserDefaults *user1 = [NSUserDefaults standardUserDefaults];
        NSString* UserName = [user1 objectForKey:@"userName"];
        self.GuideCode = [user1 objectForKey:@"UserCode"];
        daogouname=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth-200,  25/2,180,15)];
        [daogouname setTitle:UserName forState:UIControlStateNormal];
        daogouname.titleLabel.font=[UIFont systemFontOfSize:15];
        daogouname.titleLabel.textAlignment=NSTextAlignmentRight;
        daogouname.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        //[daogouname addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [daogouname setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [view1 addSubview:daogouname];
        
        
        view2=[[UIView alloc]initWithFrame:CGRectMake(0, 40+10, ScreenWidth, 250/2)];
        view2.backgroundColor=[UIColor whiteColor];
        [view1 addSubview:view2];
        UIButton*jiantou = [[UIButton alloc]init];
        jiantou.frame = CGRectMake(ScreenWidth-30,70/2-7,8, 13);
        [jiantou setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
        [jiantou addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:jiantou];
        
        NSString *s = [NSString stringWithFormat:@"%@(%@)",   commdity.userName, commdity.Phone];
        UIFont *font = [UIFont systemFontOfSize:16];
        CGSize size = CGSizeMake(320, 2000);
        CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:NSLineBreakByCharWrapping];
        huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 12, labelsize.width+3, 16)];
        huiyuanname.text=[NSString stringWithFormat:@"%@(%@)",   commdity.userName, commdity.Phone];
        huiyuanname.textColor=[UIColor blackColor];
        huiyuanname.font=[UIFont systemFontOfSize:16];
        [view2 addSubview:huiyuanname];
        suobtn=[[UIButton alloc]initWithFrame:CGRectMake(150, 12, ScreenWidth,60)];
        [suobtn addTarget:self action:@selector(xiangqing:) forControlEvents:UIControlEventTouchUpInside];
        [view2 addSubview:suobtn];
        Seximage=[[UIImageView alloc]initWithFrame:CGRectMake(huiyuanname.right, 12, 20, 20)];
        if (![commdity.Sex isEqual:[NSNull null]]) {
            
            if ([commdity.Sex isEqualToString:@"男"]) {
                
                
                Seximage.image=[UIImage imageNamed:@"nan"];
                
            }else{
                
                Seximage.image=[UIImage imageNamed:@"nv"];
                
            }
            
            [view2 addSubview:Seximage];
            
        }
        
        huiyuanname=[[UILabel alloc]initWithFrame:CGRectMake(15, 30, ScreenWidth-30, 30)];
        huiyuanname.text=[NSString stringWithFormat:@"%@",  commdity.adress];
        huiyuanname.textColor=shenhuicolor;
        huiyuanname.numberOfLines=2;
        huiyuanname.font=[UIFont systemFontOfSize:13];
        [view2 addSubview:huiyuanname];
        
        diview=[[UIView alloc]initWithFrame:CGRectMake(0, 70, ScreenWidth, 10)];
        diview.backgroundColor=zuiqianhuicolor;
        [view2 addSubview:diview];
        UILabel *line911=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
        line911.backgroundColor=qianhuicolor;
        [diview addSubview:line911];
        UILabel *line91=[[UILabel alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 0.35)];
        line91.backgroundColor=qianhuicolor;
        [diview addSubview:line91];
        
        UILabel*shangpingxinxi=[[UILabel alloc]initWithFrame:CGRectMake(15,diview.bottom, 80, 45)];
        shangpingxinxi.text=@"商品信息";
        shangpingxinxi.textColor=[UIColor blackColor];
        shangpingxinxi.font=[UIFont systemFontOfSize:sixteenORfifteenFot];
        [view2 addSubview:shangpingxinxi];
        UILabel *lineLabe=[[UILabel alloc] initWithFrame:CGRectMake(10, shangpingxinxi.bottom-0.35, ScreenWidth-20, 0.35)];
        lineLabe.backgroundColor=qianhuicolor;
        [view2 addSubview:lineLabe];
        
        
        table .tableHeaderView=view1;
        
      
        
        footview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 300)];
        
        
        UIView* diseview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
        diseview.backgroundColor=zuiqianhuicolor;
        [footview addSubview:diseview];
        UILabel *lineLabe0=[[UILabel alloc] initWithFrame:CGRectMake(0,0, ScreenWidth, 0.35)];
        lineLabe0.backgroundColor=qianhuicolor;
        [diseview addSubview:lineLabe0];
        UILabel *lineLabe9=[[UILabel alloc] initWithFrame:CGRectMake(0,10-0.35, ScreenWidth, 0.35)];
        lineLabe9.backgroundColor=qianhuicolor;
        [diseview addSubview:lineLabe9];
        UILabel* leixin=[[UILabel alloc]initWithFrame:CGRectMake(15, 10, 80, 45)];
        leixin.text=[NSString stringWithFormat:@"服务类型"];
        leixin.textColor=shenhuicolor;
        leixin.font=[UIFont systemFontOfSize:15];
        [footview addSubview:leixin];
        
        fuwuTextFied=[[UITextField alloc]initWithFrame:CGRectMake(170/2,10, ScreenWidth*300/750,45)];
        fuwuTextFied.borderStyle = UITextBorderStyleNone;
        fuwuTextFied.keyboardType = UIKeyboardTypeDecimalPad;
        fuwuTextFied.font = [UIFont systemFontOfSize: 14];
        fuwuTextFied.textColor=[UIColor blackColor];
        fuwuTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
        fuwuTextFied.tag=6;
        fuwuTextFied.placeholder = @"请选择服务类型"; //默认显示的字
        fuwuTextFied.delegate = self;
        //        [fuwuTextFied addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        [fuwuTextFied setUserInteractionEnabled:NO];
        fuwuTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
        [footview addSubview:fuwuTextFied];
        UIButton*jiant = [[UIButton alloc] initWithFrame:CGRectMake(90,10,ScreenWidth, 45)];
        [jiant addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [footview addSubview:jiant];
        UIButton*jiantouBtn12 = [[UIButton alloc] initWithFrame:CGRectMake(ScreenWidth-30,25,8, 13)];
        [jiantouBtn12 setImage:[UIImage imageNamed:@"xiangzuo-.png"] forState:UIControlStateNormal];
        [jiantouBtn12 addTarget:self action:@selector(xuanzhidaogou:) forControlEvents:UIControlEventTouchUpInside];
        [footview addSubview:jiantouBtn12];
        
        
        
        
        
        UIView* diseview1=[[UIView alloc]initWithFrame:CGRectMake(0, 45+10, ScreenWidth, 10)];
        diseview1.backgroundColor=zuiqianhuicolor;
        [footview addSubview:diseview1];
        UILabel *lineLabel11111=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
        lineLabel11111.backgroundColor=qianhuicolor;
        [diseview1 addSubview:lineLabel11111];
        UILabel *lineLabel11=[[UILabel alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 0.35)];
        lineLabel11.backgroundColor=qianhuicolor;
        [diseview1 addSubview:lineLabel11];
        
        UILabel* jine=[[UILabel alloc]initWithFrame:CGRectMake(15, diseview1.bottom, 80, 50)];
        jine.text=[NSString stringWithFormat:@"服务金额"];
        jine.textColor=shenhuicolor;
        jine.font=[UIFont systemFontOfSize:15];
        [footview addSubview:jine];
        
        xianjinTextFied=[[UITextField alloc]initWithFrame:CGRectMake(170/2,diseview1.bottom, ScreenWidth*300/750,50)];
        xianjinTextFied.borderStyle = UITextBorderStyleNone;
        xianjinTextFied.keyboardType = UIKeyboardTypeDecimalPad;
        xianjinTextFied.font = [UIFont systemFontOfSize: 14];
        xianjinTextFied.textColor=[UIColor blackColor];
        xianjinTextFied.autocapitalizationType = UITextAutocapitalizationTypeSentences;
        xianjinTextFied.tag=6;
        xianjinTextFied.placeholder = @"请输入服务金额"; //默认显示的字
        xianjinTextFied.delegate = self;
        [xianjinTextFied addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
        [xianjinTextFied setUserInteractionEnabled:YES];
        xianjinTextFied.clearButtonMode = UITextFieldViewModeWhileEditing;
        [footview addSubview:xianjinTextFied];
        
        
        
        
        UIView* diseview2=[[UIView alloc]initWithFrame:CGRectMake(0, xianjinTextFied.bottom, ScreenWidth, 10)];
        diseview2.backgroundColor=zuiqianhuicolor;
        [footview addSubview:diseview2];
        
        UILabel *lineLab=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 0.35)];
        lineLab.backgroundColor=qianhuicolor;
        [diseview2 addSubview:lineLab];
        UILabel *lineLab5=[[UILabel alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 0.35)];
        lineLab5.backgroundColor=qianhuicolor;
        [diseview2 addSubview:lineLab5];
        
        
        UIView* myToolBar=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, viewheight)];
        myToolBar.backgroundColor=jianpancolor;
        UIButton*  tubtnDone=[[UIButton alloc]initWithFrame:CGRectMake(logoX,logoY, logoheight, logowidth)];
        [tubtnDone setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [tubtnDone addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:tubtnDone];
        UIButton*btnDone111=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width - 55, 12, 40, 16)];
        [btnDone111 setTitle:@"确定" forState:UIControlStateNormal];
        [btnDone111 setTitleColor:jianpancolor1 forState:UIControlStateNormal];
        btnDone111 .titleLabel .font=[UIFont systemFontOfSize:daxiao];
        [btnDone111 addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:btnDone111];
        myToolBar.alpha=alp;
        UIButton* dabtn=[[UIButton alloc]initWithFrame:CGRectMake(myToolBar.frame.size.width-60, 0, 60, 40)];
        [dabtn addTarget:self action:@selector(OnTapDone) forControlEvents:UIControlEventTouchUpInside];
        [myToolBar addSubview:dabtn];
        
        
        tv=[[UITextView alloc]init];
        tv.frame=CGRectMake(15, diseview2.bottom+10, ScreenWidth-30, ScreenHeight*185/1334);
        tv.backgroundColor = [UIColor whiteColor];//设置它的背景颜色/Users/jiezsoft/Desktop/
        tv.scrollEnabled = YES;//是否可以拖动
        tv.delegate=self;
        //                tv.autoresizingMask = UIViewAutoresizingFlexibleHeight;//自适应高
        tv.font = [UIFont fontWithName:@"Arial" size:15.0];//设置字体名字和字体大小
        tv.layer.borderWidth =0;
        CGColorSpaceRef registedSpace11 = CGColorSpaceCreateDeviceRGB();
        CGColorRef tureBTncolorref111 = CGColorCreate(registedSpace11,(CGFloat[]){ 0, 0, 0, 0.3 });
        //                tv.keyboardType = UIKeyboardTypePhonePad;
        [tv.layer setBorderColor:tureBTncolorref111];//边框颜色
        tv.layer.cornerRadius =0;
        [footview addSubview:tv];
        imagess=[[UIImageView alloc]initWithFrame:CGRectMake(10, 8,20, 15)];
        imagess.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [tv addSubview:imagess];
        label=[[UILabel alloc]init];
        label.frame =CGRectMake(38, 8, ScreenWidth-60, 15);
        label.text = @"描述";
        label.textColor=zuiqianhuicolor;
        label.numberOfLines=0;
        label.font=[UIFont systemFontOfSize:15];
        label.enabled = NO;//lable必须设置为不可用
        label.backgroundColor = [UIColor clearColor];
        [tv addSubview:label];
        
        
        xianjinTextFied.inputAccessoryView = myToolBar;
        tv.inputAccessoryView = myToolBar;
        
        
        
        table .tableFooterView=footview;
        
        [table reloadData];
        
        
        
        [hejibuyBtn1 removeFromSuperview];
        [buyBtn2 removeFromSuperview];
        
        hejibuyBtn1=[[UIButton alloc]initWithFrame:CGRectMake(0, ScreenHeight-48, ScreenWidth*430/750, 48)];
        [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"合计%@",@"0"] forState:UIControlStateNormal];
        hejibuyBtn1.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1.0];
        [hejibuyBtn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        hejibuyBtn1.alpha=0.8;
        hejibuyBtn1.titleLabel.textAlignment=NSTextAlignmentLeft;
        
         hejibuyBtn1.titleLabel.font=[UIFont systemFontOfSize:titleNamefot];
        [self.view addSubview:hejibuyBtn1];
        
        buyBtn2=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*430/750, ScreenHeight-48, ScreenWidth*320/750, 48)];
        [buyBtn2 setTitle:@"服务登记" forState:UIControlStateNormal];
        buyBtn2.backgroundColor=luseColor;
        [buyBtn2 addTarget:self action:@selector(ture:) forControlEvents:UIControlEventTouchUpInside];
         buyBtn2.titleLabel.font=[UIFont systemFontOfSize:titleNamefot];
        [buyBtn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.view addSubview:buyBtn2];
        
        
        
        
    }
}




-(void)ture:(UIButton*)sender{
    NSLog(@"%@",self.DocType);
    
    if (commdity.content ==nil )
    {
        [self showAlertMessage:@"请选择服务类型"];
    }
    else{
        
        if ([xianjinTextFied.text length] <1)
                    {
                        [self showAlertMessage:@"请输入服务金额"];
                    }
                    else{
        
        NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
        NSString* Token = [user objectForKey:@"tokenId"];
        NSMutableDictionary *params = [NSMutableDictionary new];
        [params setValue:Token forKey:@"tokenId"];
        [params setValue:commdity.code forKey:@"serviceTypeCode"];
                        
                        
        [params setValue:tv.text forKey:@"predictDesc"];
        [params setValue:self.memberId forKey:@"memberId"];
        [params setValue:commdity.userName forKey:@"memberName"];
        [params setValue:xianjinTextFied.text forKey:@"predictMoney"];
//        [params setValue:orderItemIds forKey:@"orderItemIds"];
                        NSMutableArray *mDocumentLine=[NSMutableArray array];
                        
                        
                        for (int i=0; i<orderItemIds.count; i++) {
                            
                            NSMutableDictionary *dic = [NSMutableDictionary dictionary];
                            NSString *itemIdstr = [orderItemIds objectAtIndex:i];
                            NSString *quantitystr =[selectshuliangArray objectAtIndex:i];
                            [dic setValue:quantitystr forKey:@"quantity"];
                            [dic setValue:itemIdstr forKey:@"oItemId"];
                            [mDocumentLine addObject:dic];
                            
                            
                        }
                        [params setValue:mDocumentLine  forKey:@"orderItems"];
        [Global showIndeterminateHudSub:@"加载中，请稍后。。。" delay:30 view:self.view];
        
         
        [HttpRequest requestData:@"/Business/Service/Add" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                
                NSLog(@"%@",severDataDict.dataDict);
                
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                  
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    // [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    commdity.Dicts=nil;
                    [self.navigationController popViewControllerAnimated:YES];

                                        
                    
                    
                    
                }else{
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    // [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                }
                
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                
                [Global showTextHudSub:@"连接失败" view:self.view];
            }
            
        }];
        
        
    }}

}




-(void)xuanzhidaogou:(id)sender
{
    
     commdity.xiangqing=@"wu";
    reasonTypeViewController *detailViewController = [[reasonTypeViewController alloc] init];
    detailViewController.optionName=@"ServiceType";
    detailViewController.titlename=@"选择理由";
    [self.navigationController pushViewController:detailViewController animated:YES];
    
    
}

- (void)textFieldDidBeginEditing:(UITextField *)textField{
    
     if (textField.tag == 6)
    {
        
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        table .frame =CGRectMake(0, -200, ScreenWidth, ScreenHeight);
        [UIView commitAnimations];
    
        
    }

}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        table .frame =CGRectMake(0, -250, ScreenWidth, ScreenHeight);
        [UIView commitAnimations];
        
        
    
    return self;
}



//回收键盘
-(void)OnTapDone{
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table .frame =CGRectMake(0, 64, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    [xianjinTextFied resignFirstResponder];
    [tv resignFirstResponder];
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:xianjinTextFied.text.doubleValue]];
    
    [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"合计￥%@",formattedNumberString] forState:UIControlStateNormal];

    
}
-(void)closeKeyBoad
{
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setPositiveFormat:@"###,##0.00;"];
    NSString *formattedNumberString = [numberFormatter stringFromNumber:[NSNumber numberWithDouble:xianjinTextFied.text.doubleValue]];
    [toumingtu removeFromSuperview];
    [xiugaiview removeFromSuperview];
    
    
    [hejibuyBtn1 setTitle:[NSString stringWithFormat:@"合计￥%@",formattedNumberString] forState:UIControlStateNormal];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    table .frame =CGRectMake(0, 64, ScreenWidth, ScreenHeight);
    [UIView commitAnimations];
    
    [xianjinTextFied resignFirstResponder];
    [tv resignFirstResponder];
}



- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    
    //    if (textField.tag == 5)
    //    {
    
    if (range.location >= 9){
        return NO;
    }
    if ([textField.text rangeOfString:@"."].location==NSNotFound) {
        isHaveDian=NO;
    }
    if ([string length]>0)
    {
        unichar single=[string characterAtIndex:0];//当前输入的字符
        if ((single >='0' && single<='9') || single=='.')//数据格式正确
        {
            //首字母不能为0和小数点
            if([textField.text length]==0){
                if(single == '.'){
                    
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                    
                }
                //                    if (single == '0') {
                //                        // [self alertView:@"亲，第一个数字不能为0"];
                //                        [textField.text stringByReplacingCharactersInRange:range withString:@""];
                //                        return NO;
                //
                //                    }
            }
            if (single=='.')
            {
                if(!isHaveDian)//text中还没有小数点
                {
                    isHaveDian=YES;
                    return YES;
                }else
                {
                    //[self alertView:@"亲，您已经输入过小数点了"];
                    [textField.text stringByReplacingCharactersInRange:range withString:@""];
                    return NO;
                }
            }
            else
            {
                if (isHaveDian)//存在小数点
                {
                    //判断小数点的位数
                    NSRange ran=[textField.text rangeOfString:@"."];
                    int tt=range.location-ran.location;
                    if (tt <= 2){
                        return YES;
                    }else{
                        //[self alertView:@"亲，您最多输入两位小数"];
                        return NO;
                    }
                }
                else
                {
                    return YES;
                }
            }
        }else{//输入的数据格式不正确
            //[self alertView:@"亲，您输入的格式不正确"];
            [textField.text stringByReplacingCharactersInRange:range withString:@""];
            return NO;
        }
    }
    
    
    
    
    
    
    return YES;
    
    
    
    
    
}


- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}

- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
-(void)textViewDidChange:(UITextView *)textView
{
    //self.examineText =  textView.text;
    
    
    if (textView.text.length == 0) {
        [imagess removeFromSuperview];
        
        imagess=[[UIImageView alloc]initWithFrame:CGRectMake(10, 8, 20,15)];
        imagess.image=[UIImage imageNamed:@"_0000_xingxifankui.png"];
        [tv addSubview:imagess];
        label.text = @"描述";
        
    }else{
        [imagess removeFromSuperview];
        label.text = @"";
    }
}







@end
